package com.example.lanqiaodemo1.JavaTest;

public class ScoreException extends Exception {

    /**
     *
     */
    public ScoreException() {
        super("分数异常，分数应该在0到200之间");
    }

    public ScoreException(String message) {
        super(message);
    }
}

class Student {

    private String name;
    private int age;
    private double score;

    public Student(String name, int age, double score) throws ScoreException {
        super();
        if (score < 0 || score > 200) {
            throw new ScoreException();
        }
        this.name = name;
        this.age = age;
        this.score = score;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) { this.age = age; }

    public double getScore() { return score; }

    public void setScore(double score) throws ScoreException {
        if (score < 0 || score > 200) {
            throw new ScoreException();
        }
        this.score = score;
    }

    public Student() {
    }

    public void print() {
        System.out.println(this.name);
        System.out.println(this.age);
        System.out.println(this.score);
    }

    public static void main(String[] args) {
        try {
            Student lisi = new Student("lisi", 30, 120);
            lisi.setScore(230);
        } catch (ScoreException e) {
            System.out.println(e.getMessage());
        }

    }


}